import java.util.LinkedList;

public class myQuene {

    static class linkedList{
        linkedList prev;
        linkedList next;
        int val;
        public linkedList(int val){
            this.val = val;
        }
    }

    public linkedList first;
    public linkedList last;
    public  int usesize;

    public void enqueue(int val){
        linkedList temp = new linkedList(val);
        if(first == null){
            first = last = temp;
        }else {
            last.next = temp;
            temp.prev = last;
            last = temp;
        }
        usesize++;
    }

    public int dequeue() {
        if (first == null) {
            return -1;
        } else {
            // 保存原队首节点的值
            int val = first.val;
            if (first.next == null) {
                last = null;
            } else {
                first.next.prev = null;
            }
            // 移除原队首节点
            first = first.next;
            usesize--;
            // 返回原队首节点的值
            return val;
        }
    }

    public boolean isEmpty(){
        return first == null;
    }

    public int peek(){
        if(first == null){
            return -1;
        }else {
            return first.val;
        }
    }
}
